var file = File('F://淘宝店铺4/2.jpg');
open(file);
var fileObj = app.activeDocument;
if (/2\./.test(fileObj.name))
alert(222)
var newFile = File('F://淘宝店铺4/3.jpg');

var saveOptions = new JPEGSaveOptions();
saveOptions.quality = 12
fileObj.saveAs(newFile, saveOptions, true);
fileObj.close(SaveOptions.DONOTSAVECHANGES)

open(newFile)
fileObj = app.activeDocument;
fileObj.crop(getStart(fileObj));

fileObj.resizeImage(800, 800, 72, ResampleMethod.AUTOMATIC, 0);

fileObj.close(SaveOptions.SAVECHANGES);

function getStart(doc, needSize) {
  var width = doc.width;
  var height = doc.height;
  needSize = needSize || Math.min(width, height);
  var halfNeedSize = needSize / 2;

  var left = width > needSize ? width / 2 - halfNeedSize : 0;
  var top = height > needSize ? height / 2 - halfNeedSize : 0;

  return [left, top, width > needSize ? left + needSize : width, height > needSize ? top + needSize : height]
}